<link type="text/css" rel="stylesheet" href="./css/bootstrap.min.css" />
<link type="text/css" rel="stylesheet" href="./css/bootstrap-dialog.min.css">
<link type="text/css" rel="stylesheet" href="./css/commone.css" />
<script type="text/javascript" src="./js/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="./js/bootstrap.min.js"></script>
<script type="text/javascript">
	function mdoifyPass(){
		$.isSubmit = true;
		var password = $.verifyForm($('input.password'), true);
		var passwordConfirm = $.verifyForm($('input.password-confirm'), true);
		if(!$.isSubmit) return;
		if(password != passwordConfirm){
			BootstrapDialog.msg("再次密码输入不一致!", BootstrapDialog.TYPE_PRIMARY);
			return;
		}
		$.getJSON('mgr/mdoifyPass', {password : password}, function(data){
			if(!$.isSuccess(data)) return;
			BootstrapDialog.hideModel($('div.update-password-box'));
			BootstrapDialog.msg(data.body, BootstrapDialog.TYPE_SUCCESS);
		});
	}
	
	BootstrapDialog.msg = function(message, type){
		new BootstrapDialog({
			title : '提示信息',
			message : message, 
			type : type,
			closeabled : false,
			backdrop : 'static'
		}).open();
	};
	
	(function($) {
		$.isSubmit = true;	// 是否可提交
		$.verifyForm = function(eml, isEmpty){
			eml.removeClass('empty');
			if(!isEmpty) return eml.val();
			var val = eml.val();
			if(val < 1 || val.length < 1){
				$.isSubmit = false;
				eml.addClass('empty');
			}
			return val;
		};
		// 判断返回数据的JSON头是成功还是失败
		$.isSuccess = function(data) {
			if(data.head) return data.head;
			if(!data.body) return;
			if((data.body == 'PERMISSION_DENIED' || data.body == 'UNLOGIN') && dialog != null){
				dialog.close();
				if(data.body == 'UNLOGIN'){
					BootstrapDialog.show({
						title : "错误",
						type : BootstrapDialog.TYPE_DANGER,
						message : data.body,
						onhide : function(dialog){window.location.href="./login.html"; }
					});
					return;
				}
			}
			BootstrapDialog.show({
				title : "错误",
				type : BootstrapDialog.TYPE_DANGER,
				message : data.body
			});
			return data.head;
		};
	})(jQuery);
</script>

<div class='modal-header'><h4 class='modal-title'>修改密码</h4></div>
<div class='modal-body'>
	<table>
		<tr class='login-tr'>
			<td class='login-key'>新密码:</td>
			<td class='login-val'><input type='password' maxlength='32' class='form-control login-input password' placeholder='新密码' /></td>
		</tr>
		<tr class='login-tr'>
			<td class='login-key'>确认新密码:</td>
			<td class='login-val'><input type='password' maxlength='32' class='form-control login-input password-confirm' placeholder='确认新密码 www.te5L.com' />
			</td>
		</tr>
	</table>
</div>
<div class='modal-footer'>
	<button type='button' class='btn btn-default' data-dismiss='modal'>取消</button>
	<button type='button' class='btn btn-primary' onclick='mdoifyPass()'>修改</button>
</div>

